﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace EVEApi
{
    public partial class Form1 : Form
    {

        DataSet DS = new DataSet();
        DataTable DT = new DataTable();
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {


        }

        private void button2_Click(object sender, EventArgs e)
        {
            ButtonState(false);
            API api = new API();
            api.APIBereit += new EventHandler(api_APIBereit);
            DataTable DT = new DataTable();
            DT = api.CharacterLoad();
            comboBox1.DataSource = DT;
            comboBox1.DisplayMember = "name";
            comboBox1.ValueMember = "characterID";
            
        }

        private void ButtonState(bool Enable)
        {
            if (Enable) {
                button1.Enabled = true;
                button2.Enabled = true;
                button3.Enabled = true;

            } else {
                button1.Enabled = false;
                button2.Enabled = false;
                button3.Enabled = false;
            }
        }

        void api_APIBereit(object sender, EventArgs e)
        {
         
            ButtonState(true);
        }

        private void button3_Click(object sender, EventArgs e)
        {
            ButtonState(false);
            API api = new API();
            api.APIBereit += new EventHandler(api_APIBereit);
           DT = api.TransactionLoad(comboBox1.SelectedValue.ToString());
           dataGridView1.DataSource = DT;
        }

        private void button4_Click(object sender, EventArgs e)
        {
            Datenbank DB = new Datenbank();
            DB.TabellenErstellen();
        }

        private void button5_Click(object sender, EventArgs e)
        {
            Datenbank DB = new Datenbank();
            DB.InDatenbankSpeichern(DT);
        }
    }
}
